/*********************************************************************************************************************
* CH32V307VCT6 Opensourec Library 锟斤拷锟斤拷CH32V307VCT6 锟斤拷源锟解）锟斤拷一锟斤拷锟斤拷锟节官凤拷 SDK 锟接口的碉拷锟斤拷锟斤拷锟斤拷源锟斤拷
* Copyright (c) 2022 SEEKFREE 锟斤拷煽萍锟�
*
* 锟斤拷锟侥硷拷锟斤拷CH32V307VCT6 锟斤拷源锟斤拷锟揭伙拷锟斤拷锟�
*
* CH32V307VCT6 锟斤拷源锟斤拷 锟斤拷锟斤拷锟斤拷锟斤拷锟�
* 锟斤拷锟斤拷锟皆革拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷岱拷锟斤拷锟� GPL锟斤拷GNU General Public License锟斤拷锟斤拷 GNU通锟矫癸拷锟斤拷锟斤拷锟斤拷证锟斤拷锟斤拷锟斤拷锟斤拷
* 锟斤拷 GPL 锟侥碉拷3锟芥（锟斤拷 GPL3.0锟斤拷锟斤拷锟斤拷选锟斤拷模锟斤拷魏魏锟斤拷锟斤拷陌姹撅拷锟斤拷锟斤拷路锟斤拷锟斤拷锟�/锟斤拷锟睫革拷锟斤拷
*
* 锟斤拷锟斤拷源锟斤拷姆锟斤拷锟斤拷锟较ｏ拷锟斤拷锟斤拷芊锟斤拷锟斤拷锟斤拷茫锟斤拷锟斤拷锟轿达拷锟斤拷锟斤拷锟斤拷魏蔚谋锟街�
* 锟斤拷锟斤拷没锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟皆伙拷锟绞猴拷锟截讹拷锟斤拷途锟侥憋拷证
* 锟斤拷锟斤拷细锟斤拷锟斤拷渭锟� GPL
*
* 锟斤拷应锟斤拷锟斤拷锟秸碉拷锟斤拷锟斤拷源锟斤拷锟酵憋拷盏锟揭伙拷锟� GPL 锟侥革拷锟斤拷
* 锟斤拷锟矫伙拷校锟斤拷锟斤拷锟斤拷<https://www.gnu.org/licenses/>
*
* 锟斤拷锟斤拷注锟斤拷锟斤拷
* 锟斤拷锟斤拷源锟斤拷使锟斤拷 GPL3.0 锟斤拷源锟斤拷锟斤拷证协锟斤拷 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷为锟斤拷锟侥版本
* 锟斤拷锟斤拷锟斤拷锟斤拷英锟侥帮拷锟斤拷 libraries/doc 锟侥硷拷锟斤拷锟铰碉拷 GPL3_permission_statement.txt 锟侥硷拷锟斤拷
* 锟斤拷锟斤拷证锟斤拷锟斤拷锟斤拷 libraries 锟侥硷拷锟斤拷锟斤拷 锟斤拷锟斤拷锟侥硷拷锟斤拷锟铰碉拷 LICENSE 锟侥硷拷
* 锟斤拷迎锟斤拷位使锟矫诧拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 锟斤拷锟睫革拷锟斤拷锟斤拷时锟斤拷锟诫保锟斤拷锟斤拷煽萍锟斤拷陌锟饺拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
*
* 锟侥硷拷锟斤拷锟斤拷          isr
* 锟斤拷司锟斤拷锟斤拷          锟缴讹拷锟斤拷煽萍锟斤拷锟斤拷薰锟剿�
* 锟芥本锟斤拷息          锟介看 libraries/doc 锟侥硷拷锟斤拷锟斤拷 version 锟侥硷拷 锟芥本说锟斤拷
* 锟斤拷锟斤拷锟斤拷锟斤拷          MounRiver Studio V1.8.1
* 锟斤拷锟斤拷平台          CH32V307VCT6
* 锟斤拷锟斤拷锟斤拷锟斤拷          https://seekfree.taobao.com/
*
* 锟睫改硷拷录
* 锟斤拷锟斤拷                                      锟斤拷锟斤拷                             锟斤拷注
* 2022-09-15        锟斤拷W            first version
********************************************************************************************************************/

#include "zf_common_headfile.h"
#include "PID.h"
#include "My_camera.h"
#include "gyro.h"
#include "KEY.h"
#include "adc.h"
void NMI_Handler(void)       __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));

void USART1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void USART2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void USART3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART4_IRQHandler (void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART5_IRQHandler (void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART6_IRQHandler (void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART7_IRQHandler (void) __attribute__((interrupt("WCH-Interrupt-fast")));
void UART8_IRQHandler (void) __attribute__((interrupt("WCH-Interrupt-fast")));
void DVP_IRQHandler (void) __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM1_BRK_IRQHandler        (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM1_UP_IRQHandler         (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM1_TRG_COM_IRQHandler    (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM1_CC_IRQHandler         (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM2_IRQHandler            (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM3_IRQHandler            (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM4_IRQHandler            (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM5_IRQHandler            (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM6_IRQHandler            (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM7_IRQHandler            (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM8_BRK_IRQHandler        (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM8_UP_IRQHandler         (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM8_TRG_COM_IRQHandler    (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM8_CC_IRQHandler         (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM9_BRK_IRQHandler        (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM9_UP_IRQHandler         (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM9_TRG_COM_IRQHandler    (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM9_CC_IRQHandler         (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM10_BRK_IRQHandler       (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM10_UP_IRQHandler        (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM10_TRG_COM_IRQHandler   (void)  __attribute__((interrupt("WCH-Interrupt-fast")));
//void TIM10_CC_IRQHandler        (void)  __attribute__((interrupt("WCH-Interrupt-fast")));

void EXTI0_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void EXTI1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void EXTI2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void EXTI3_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void EXTI4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void EXTI9_5_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void EXTI15_10_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));

void USART1_IRQHandler(void)
{
    if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
    {

        USART_ClearITPendingBit(USART1, USART_IT_RXNE);
    }
}
void USART2_IRQHandler(void)
{
    if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET)
    {


        USART_ClearITPendingBit(USART2, USART_IT_RXNE);
    }
}
void USART3_IRQHandler(void)
{
    if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
    {
        wireless_ch573_callback();
#if DEBUG_UART_USE_INTERRUPT                                                    // 锟斤拷锟斤拷锟斤拷锟� debug 锟斤拷锟斤拷锟叫讹拷
        debug_interrupr_handler();                                              // 锟斤拷锟斤拷 debug 锟斤拷锟节斤拷锟秸达拷锟斤拷锟斤拷锟斤拷 锟斤拷锟捷会被 debug 锟斤拷锟轿伙拷锟斤拷锟斤拷锟斤拷取
#endif                                                                          // 锟斤拷锟斤拷薷锟斤拷锟� DEBUG_UART_INDEX 锟斤拷锟斤拷未锟斤拷锟斤拷锟揭拷诺锟斤拷锟接︼拷拇锟斤拷锟斤拷卸锟饺�
        USART_ClearITPendingBit(USART3, USART_IT_RXNE);
    }
}
void UART4_IRQHandler (void)
{
    if(USART_GetITStatus(UART4, USART_IT_RXNE) != RESET)
    {

        USART_ClearITPendingBit(UART4, USART_IT_RXNE);
    }
}
void UART5_IRQHandler (void)
{
    if(USART_GetITStatus(UART5, USART_IT_RXNE) != RESET)
    {
        camera_uart_handler();
        USART_ClearITPendingBit(UART5, USART_IT_RXNE);
    }
}
void UART6_IRQHandler (void)
{
    if(USART_GetITStatus(UART6, USART_IT_RXNE) != RESET)
    {

        USART_ClearITPendingBit(UART6, USART_IT_RXNE);
    }
}
void UART7_IRQHandler (void)
{
    if(USART_GetITStatus(UART7, USART_IT_RXNE) != RESET)
    {
        wireless_module_uart_handler();
        USART_ClearITPendingBit(UART7, USART_IT_RXNE);
    }
}
void UART8_IRQHandler (void)
{
    if(USART_GetITStatus(UART8, USART_IT_RXNE) != RESET)
    {
        gps_uart_callback();
        USART_ClearITPendingBit(UART8, USART_IT_RXNE);
    }

}



void DVP_IRQHandler(void)
{
    if (DVP->IFR & RB_DVP_IF_FRM_DONE)
    {
        camera_dvp_handler();
        DVP->IFR &= ~RB_DVP_IF_FRM_DONE;
    }
}
void EXTI0_IRQHandler(void)
{
    if(SET == EXTI_GetITStatus(EXTI_Line0))
    {
        EXTI_ClearITPendingBit(EXTI_Line0);

    }
}

void EXTI1_IRQHandler(void)
{
    if(SET == EXTI_GetITStatus(EXTI_Line1))
    {
        EXTI_ClearITPendingBit(EXTI_Line1);

    }
}

void EXTI2_IRQHandler(void)
{
    if(SET == EXTI_GetITStatus(EXTI_Line2))
    {
        EXTI_ClearITPendingBit(EXTI_Line2);

    }
}

void EXTI3_IRQHandler(void)
{
    if(SET == EXTI_GetITStatus(EXTI_Line3))
    {
        EXTI_ClearITPendingBit(EXTI_Line3);

    }
}

void EXTI4_IRQHandler(void)
{
    if(SET == EXTI_GetITStatus(EXTI_Line4))
    {
        EXTI_ClearITPendingBit(EXTI_Line4);

    }
}


void EXTI9_5_IRQHandler(void)
{
    if(SET == EXTI_GetITStatus(EXTI_Line5))
    {
        EXTI_ClearITPendingBit(EXTI_Line5);

    }
    if(SET == EXTI_GetITStatus(EXTI_Line6))
    {
        EXTI_ClearITPendingBit(EXTI_Line6);

    }
    if(SET == EXTI_GetITStatus(EXTI_Line7))
    {
        EXTI_ClearITPendingBit(EXTI_Line7);

    }
    if(SET == EXTI_GetITStatus(EXTI_Line8))
    {
        EXTI_ClearITPendingBit(EXTI_Line8);

    }
    if(SET == EXTI_GetITStatus(EXTI_Line9))
    {
        EXTI_ClearITPendingBit(EXTI_Line9);

    }

}

void EXTI15_10_IRQHandler(void)
{
    if(SET == EXTI_GetITStatus(EXTI_Line10))
    {
        EXTI_ClearITPendingBit(EXTI_Line10);

    }
    if(SET == EXTI_GetITStatus(EXTI_Line11))
    {
        EXTI_ClearITPendingBit(EXTI_Line11);

    }
    if(SET == EXTI_GetITStatus(EXTI_Line12))
    {
        EXTI_ClearITPendingBit(EXTI_Line12);

    }
    if(SET == EXTI_GetITStatus(EXTI_Line13))
    {
        EXTI_ClearITPendingBit(EXTI_Line13);

    }
    if(SET == EXTI_GetITStatus(EXTI_Line14))
    {
        // -----------------* DM1XA 锟斤拷锟脚猴拷 预锟斤拷锟叫断达拷锟斤拷锟斤拷锟斤拷 *-----------------
        dm1xa_light_callback();
        // -----------------* DM1XA 锟斤拷锟脚猴拷 预锟斤拷锟叫断达拷锟斤拷锟斤拷锟斤拷 *-----------------
        EXTI_ClearITPendingBit(EXTI_Line14);
    }
    if(SET == EXTI_GetITStatus(EXTI_Line15))
    {
        // -----------------* DM1XA 锟斤拷/锟斤拷锟斤拷锟脚猴拷 预锟斤拷锟叫断达拷锟斤拷锟斤拷锟斤拷 *-----------------
        dm1xa_sound_callback();
        // -----------------* DM1XA 锟斤拷/锟斤拷锟斤拷锟脚猴拷 预锟斤拷锟叫断达拷锟斤拷锟斤拷锟斤拷 *-----------------
        EXTI_ClearITPendingBit(EXTI_Line15);
    }
}



void TIM1_UP_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET)
    {
        TIM_ClearITPendingBit(TIM1, TIM_IT_Update);

    }
}


void TIM2_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
    {
       TIM_ClearITPendingBit(TIM2, TIM_IT_Update );


    }
}

#include "attitude_solution.h"
#include "KEY.h"
int left_s = 0;
int right_s = 0;
int Sp_count = 0;
extern int16 encoder_data1;
extern int16 encoder_data2;
extern uint8 Pixle[LCDH][LCDW];
int clear = 1;
extern uint8 KeyNum;
extern uint8 menu_dis;
uint8 fork_flag=0;
int State_flag=2;//发车状态
int count=0;
int start_count=0;
int T_count=0;
extern uint8 Ru_ku;
int lenth=0;
int start = 0;
int start_flag=0;
int flag = 0;
int cut_flag = 0;
extern uint8 KeyNum;
int contrl_count = 0;
int speed_change = 0;

extern uint8 Car_Go;
extern ImageStatustypedef ImageStatus;  //图锟斤拷锟饺拷直锟斤拷锟�
uint8 cut = 0;
extern uint8 ciki;
int bizhan=0;
int distance=0;
float step = 0;
uint8 huannei = 0;
int flag_two=0;
int flag_3=0;
int stop = 0;
int flag_one=0;
int go=0;
extern int count_l;
extern int count_r;
uint8 Lock_motor = 0;
uint8 Lock_gyro = 0;
void TIM3_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)
    {

        encoder_data1 = encoder_get_count(TIM9_ENCOEDER);                      // 锟斤拷取锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
        encoder_clear_count(TIM9_ENCOEDER);                                   // 锟斤拷毡锟斤拷锟斤拷锟斤拷锟斤拷锟�
        encoder_data2 = -encoder_get_count(TIM1_ENCOEDER);                      // 锟斤拷取锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
        encoder_clear_count(TIM1_ENCOEDER);

        if(State_flag==2)
        {
            ICM_hubu();
        }
        if (ImageStatus.IsCinqueOutIn == 'T')
        {
            if(huannei==0)
            {
               ICM_hubu();
            }
        }
        if(huannei==1)
        {

            ImageStatus.CirquePass='T';
            ImageStatus.IsCinqueOutIn = 'F';
            huannei = 0;
        }

        switch(State_flag)
        {
            case 0:
            if(Lock_motor==0)
            {
                step += (encoder_data1+encoder_data2)/2530.0f;
                if(step>3)
                {
                    Lock_motor = 1;
                }
            }
            if(Car_Go==1)
            {
               pwm_set_duty(TIM2_PWM_MAP3_CH1_A15,Mid_value+sevro());
//               pwm_set_duty(TIM2_PWM_MAP3_CH1_A15,Mid_value+adc_sevro());
            }
            if(Ru_ku==3)
            {
                step += (encoder_data1+encoder_data2)/2530.0f;
                if(step >= 5)
                {
                    flag = 1;
                    gpio_set_level(C13, 0);
                    yuansu_num=0;
//                    Ru_ku=0;
                    step=0;
                }
            }

            break;
            case 2:
            if(flag_two!=1)
            {
                pwm_set_duty(TIM2_PWM_MAP3_CH1_A15,Mid_value-75);
            }
            if(uart_data==49&&stop == 0)////当按下按键
            {
                if(yaw_angle>=78)
                    {
                        pwm_set_duty(TIM2_PWM_MAP3_CH1_A15,Mid_value);
//                        gpio_set_level(E12, 1);
                        flag_two=1;
                        flag_3=0;
                        flag_one=1;
                        stop=1;
                    }
                else {
                    flag_3=1;//出发减速标志位置1
                }
            }
            if(flag_one==1)
            {
                flag_one=0;
                uart_data=0;
            }
            if(flag_two==1)
            {
                if(uart_data==49)
                {
                    start_flag = 1;
                    yaw_angle=0;
                    flag_two=0;
                    State_flag=0;
                    Car_Go = 1;
                    go=1;
                }
            }
                break;
            case 3:
//                ICM_hubu();
                step += (encoder_data1+encoder_data2)/2530.0f;
//                Road_sim();
                pwm_set_duty(TIM2_PWM_MAP3_CH1_A15,Mid_value+adc_sevro());
            if(Pixle[58][74]==255&&step>10)
            {
                State_flag = 0;
                Target_speed = Set_speed;
                yuansu_num++;
                step = 0;
            }

            break;
            case 4://避障
                if(yaw_angle!=0&&Lock_gyro==0)
                {
                    Lock_gyro = 1;
                    yaw_angle=0;
                }

                step += (encoder_data1+encoder_data2)/2530.0f;
//                Road_sim();
//                if(step>10)
//                {
//                    bizhan = 1;
//                }
                if(step < 3&&bizhan == 0)
                {
                    pwm_set_duty(TIM2_PWM_MAP3_CH1_A15,Mid_value+42);

                }
                else {
                    pwm_set_duty(TIM2_PWM_MAP3_CH1_A15,Mid_value-52);
                    bizhan = 1;
                }
                if(Pixle[58][65]==255&&bizhan == 1&&step > 5)
                {

                    State_flag = 0;
                    yaw_angle = 0;
                    Lock_gyro = 0;
                    Ru_ku = 1;
                    bizhan = 0;
                    step = 0;
                    yuansu_num++;
                }
                break;
        }
        if(go==1)
        {
//            gpio_set_level(E12, 0);
            step += (encoder_data1+encoder_data2)/2530.0f;
            if(step>=4)
            {
                uart_write_byte(UART_3,49);
                uart_write_byte(UART_3,49);
                go = 0;
                step = 0;
            }
        }
        if(Right_adc<=5&&Left_adc<=5&&State_flag!=2&&State_flag!=4&&State_flag!=3)
        {
            flag=1;
        }
       TIM_ClearITPendingBit(TIM3, TIM_IT_Update );


    }
}
extern uint8 Car_Go;
uint8 Start=0;
int over_count = 0;
extern uint8 Barn_flag;
int rucheku = 0;
extern int compensate;
extern uint8 chuhuan;
void TIM4_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET)
    {
        if(menu_dis==1&&Start==0)
        {
            over_count++;
        }
//        contrl_count++;
        Sp_count++;
//        if(contrl_count>=20)
//        {
//            chasu = turn_w();
////            left_s = Lvelocity(encoder_data2,Target_speed-(Target_speed*chasu));
////            right_s = Rvelocity(encoder_data1,Target_speed+(Target_speed*chasu));
//            contrl_count = 0;
//        }
        if(Sp_count >= 5)
        {
            left_s = Lvelocity(encoder_data1,Target_speed-(Target_speed*turn_w()));
            right_s = Rvelocity(encoder_data2,Target_speed+(Target_speed*turn_w()));
            motor_contrl();
            Sp_count = 0;
        }

        if(ImageStatus.CirquePass=='T')
        {
            if(chuhuan==1)
            {
                step += (encoder_data1+encoder_data2)/2530.0f;
                if(step>20)
                {
                    compensate = 0;
                    count_l = 0;
                    count_r = 0;
                    ImageStatus.CirquePass='F';
                    yuansu_num++;
                    chuhuan=0;
                    gpio_set_level(C13, 0);
                    ImageStatus.CirqueOut = 'T';
                    yaw_angle=0;
//                    flag=1;
                }
            }
        }
        if(ImageStatus.CirqueOut == 'T')
        {
//            gpio_set_level(C13, 1);
            step += (encoder_data1+encoder_data2)/2530.0f;
            if(step>32)
            {
//                gpio_set_level(C13, 0);
                ImageStatus.CirqueOut='F';
                ImageStatus.CirquePass='F';
                ImageStatus.Road_type = 0;
                yaw_angle=0;
                step = 0;
                ciki = 0;
            }
        }
        if(over_count>=5000)
        {
            uart_data = 49;
            over_count = 0;
            Start=1;
        }
//        if(uart_data==49)
//        {
//            start_flag = 1;
//        }
        if(uart_data==50&&start_flag==1)
        {
            flag = 1;
            start_flag=0;
        }
        if(encoder_data1<=20&&encoder_data2<=20&&Lock_motor==1)
        {
            flag = 1;
        }
       TIM_ClearITPendingBit(TIM4, TIM_IT_Update );
    }
}

void TIM5_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM5, TIM_IT_Update) != RESET)
    {
       TIM_ClearITPendingBit(TIM5, TIM_IT_Update );


    }
}

void TIM6_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM6, TIM_IT_Update) != RESET)
    {
        get_adc();
       dl1a_get_distance();
       TIM_ClearITPendingBit(TIM6, TIM_IT_Update );

    }
}

void TIM7_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM7, TIM_IT_Update) != RESET)
    {
//        Trig_count();
       TIM_ClearITPendingBit(TIM7, TIM_IT_Update );


    }
}


void TIM8_UP_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM8, TIM_IT_Update) != RESET)
    {
        TIM_ClearITPendingBit(TIM8, TIM_IT_Update);

    }
}


void TIM9_UP_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM9, TIM_IT_Update) != RESET)
    {
        TIM_ClearITPendingBit(TIM9, TIM_IT_Update);

    }
}


void TIM10_UP_IRQHandler(void)
{
    if(TIM_GetITStatus(TIM10, TIM_IT_Update) != RESET)
    {
        TIM_ClearITPendingBit(TIM10, TIM_IT_Update);

    }
}



//.section    .text.vector_handler, "ax", @progbits

//   .weak   EXTI0_IRQHandler           /* EXTI Line 0 */
//   .weak   EXTI1_IRQHandler           /* EXTI Line 1 */
//   .weak   EXTI2_IRQHandler           /* EXTI Line 2 */
//   .weak   EXTI3_IRQHandler           /* EXTI Line 3 */
//   .weak   EXTI4_IRQHandler           /* EXTI Line 4 */
//   .weak   DMA1_Channel1_IRQHandler   /* DMA1 Channel 1 */
//   .weak   DMA1_Channel2_IRQHandler   /* DMA1 Channel 2 */
//   .weak   DMA1_Channel3_IRQHandler   /* DMA1 Channel 3 */
//   .weak   DMA1_Channel4_IRQHandler   /* DMA1 Channel 4 */
//   .weak   DMA1_Channel5_IRQHandler   /* DMA1 Channel 5 */
//   .weak   DMA1_Channel6_IRQHandler   /* DMA1 Channel 6 */
//   .weak   DMA1_Channel7_IRQHandler   /* DMA1 Channel 7 */
//   .weak   ADC1_2_IRQHandler          /* ADC1_2 */
//   .weak   USB_HP_CAN1_TX_IRQHandler  /* USB HP and CAN1 TX */
//   .weak   USB_LP_CAN1_RX0_IRQHandler /* USB LP and CAN1RX0 */
//   .weak   CAN1_RX1_IRQHandler        /* CAN1 RX1 */
//   .weak   CAN1_SCE_IRQHandler        /* CAN1 SCE */
//   .weak   EXTI9_5_IRQHandler         /* EXTI Line 9..5 */
//   .weak   TIM1_BRK_IRQHandler        /* TIM1 Break */
//   .weak   TIM1_UP_IRQHandler         /* TIM1 Update */
//   .weak   TIM1_TRG_COM_IRQHandler    /* TIM1 Trigger and Commutation */
//   .weak   TIM1_CC_IRQHandler         /* TIM1 Capture Compare */
//   .weak   TIM2_IRQHandler            /* TIM2 */
//   .weak   TIM3_IRQHandler            /* TIM3 */
//   .weak   TIM4_IRQHandler            /* TIM4 */
//   .weak   I2C1_EV_IRQHandler         /* I2C1 Event */
//   .weak   I2C1_ER_IRQHandler         /* I2C1 Error */
//   .weak   I2C2_EV_IRQHandler         /* I2C2 Event */
//   .weak   I2C2_ER_IRQHandler         /* I2C2 Error */
//   .weak   SPI1_IRQHandler            /* SPI1 */
//   .weak   SPI2_IRQHandler            /* SPI2 */
//   .weak   USART1_IRQHandler          /* USART1 */
//   .weak   USART2_IRQHandler          /* USART2 */
//   .weak   USART3_IRQHandler          /* USART3 */
//   .weak   EXTI15_10_IRQHandler       /* EXTI Line 15..10 */
//   .weak   RTCAlarm_IRQHandler        /* RTC Alarm through EXTI Line */
//   .weak   USBWakeUp_IRQHandler       /* USB Wakeup from suspend */
//   .weak   TIM8_BRK_IRQHandler        /* TIM8 Break */
//   .weak   TIM8_UP_IRQHandler         /* TIM8 Update */
//   .weak   TIM8_TRG_COM_IRQHandler    /* TIM8 Trigger and Commutation */
//   .weak   TIM8_CC_IRQHandler         /* TIM8 Capture Compare */
//   .weak   RNG_IRQHandler             /* RNG */
//   .weak   FSMC_IRQHandler            /* FSMC */
//   .weak   SDIO_IRQHandler            /* SDIO */
//   .weak   TIM5_IRQHandler            /* TIM5 */
//   .weak   SPI3_IRQHandler            /* SPI3 */
//   .weak   UART4_IRQHandler           /* UART4 */
//   .weak   UART5_IRQHandler           /* UART5 */
//   .weak   TIM6_IRQHandler            /* TIM6 */
//   .weak   TIM7_IRQHandler            /* TIM7 */
//   .weak   DMA2_Channel1_IRQHandler   /* DMA2 Channel 1 */
//   .weak   DMA2_Channel2_IRQHandler   /* DMA2 Channel 2 */
//   .weak   DMA2_Channel3_IRQHandler   /* DMA2 Channel 3 */
//   .weak   DMA2_Channel4_IRQHandler   /* DMA2 Channel 4 */
//   .weak   DMA2_Channel5_IRQHandler   /* DMA2 Channel 5 */
//   .weak   ETH_IRQHandler             /* ETH */
//   .weak   ETH_WKUP_IRQHandler        /* ETH WakeUp */
//   .weak   CAN2_TX_IRQHandler         /* CAN2 TX */
//   .weak   CAN2_RX0_IRQHandler        /* CAN2 RX0 */
//   .weak   CAN2_RX1_IRQHandler        /* CAN2 RX1 */
//   .weak   CAN2_SCE_IRQHandler        /* CAN2 SCE */
//   .weak   OTG_FS_IRQHandler          /* OTGFS */
//   .weak   USBHSWakeup_IRQHandler     /* USBHS Wakeup */
//   .weak   USBHS_IRQHandler           /* USBHS */
//   .weak   DVP_IRQHandler             /* DVP */
//   .weak   UART6_IRQHandler           /* UART6 */
//   .weak   UART7_IRQHandler           /* UART7 */
//   .weak   UART8_IRQHandler           /* UART8 */
//   .weak   TIM9_BRK_IRQHandler        /* TIM9 Break */
//   .weak   TIM9_UP_IRQHandler         /* TIM9 Update */
//   .weak   TIM9_TRG_COM_IRQHandler    /* TIM9 Trigger and Commutation */
//   .weak   TIM9_CC_IRQHandler         /* TIM9 Capture Compare */
//   .weak   TIM10_BRK_IRQHandler       /* TIM10 Break */
//   .weak   TIM10_UP_IRQHandler        /* TIM10 Update */
//   .weak   TIM10_TRG_COM_IRQHandler   /* TIM10 Trigger and Commutation */
//   .weak   TIM10_CC_IRQHandler        /* TIM10 Capture Compare */
//   .weak   DMA2_Channel6_IRQHandler   /* DMA2 Channel 6 */
//   .weak   DMA2_Channel7_IRQHandler   /* DMA2 Channel 7 */
//   .weak   DMA2_Channel8_IRQHandler   /* DMA2 Channel 8 */
//   .weak   DMA2_Channel9_IRQHandler   /* DMA2 Channel 9 */
//   .weak   DMA2_Channel10_IRQHandler  /* DMA2 Channel 10 */
//   .weak   DMA2_Channel11_IRQHandler  /* DMA2 Channel 11 */

/*******************************************************************************
* Function Name  : NMI_Handler
* Description    : This function handles NMI exception.
* Input          : None
* Return         : None
*******************************************************************************/
void NMI_Handler(void)
{
}

/*******************************************************************************
* Function Name  : HardFault_Handler
* Description    : This function handles Hard Fault exception.
* Input          : None
* Return         : None
*******************************************************************************/
void HardFault_Handler(void)
{
  while (1)
  {
  }
}


